import wx

class PlayerPanel(wx.Panel):
    def __init__(self, id, player, *args, **kwargs):
        wx.Panel.__init__(self, *args, **kwargs) 
        
        self.text = wx.StaticText(self, wx.ID_ANY, "")

    def update(self, id, player, engine):
        string = "Player: %d %s\n" % (id, player.name)
        income = player.calculate_income(engine)
        (hexes, other_hexes, workers, other_workers) = player.count_status(engine)
        
        for resource in sorted(player.resources.keys()):
            string += "%s: %d (%d)\n" % (resource, player.resources[resource], income[resource])

        string += "Hexes: %.0f%% (>50%%)\n" % ((float(hexes) / float(hexes + other_hexes) * float(100)))
        string += "Workers: %.0f%% (>50%%)\n" % ((float(workers) / float(workers + other_workers) * float(100)))

        self.text.SetLabel(string)
        
